package com.situ.mall.common.mapper;

import com.situ.mall.common.entity.Attachment;
import com.situ.mall.common.entity.Product;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.mall.common.vo.EditProductVO;
import com.situ.mall.common.vo.IndexProductVO;
import com.situ.mall.common.vo.ProductVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 闫佳宁
 * @since 2023-09-12
 */
public interface ProductMapper extends BaseMapper<Product> {

    List<ProductVO> select(@Param("name") String name, @Param("status")String status);

    @Update("Update product set status = -1 where id = #{id}")
    void delete(Integer id);

    void delete2(String[] split);

    @Select("SELECT product.*,category.parent_id 'topCategory' FROM product INNER JOIN category ON category.id = product.category_id WHERE product.id = #{id}")
    EditProductVO edit(Integer id);

    @Select("select * from product where category_id = #{id}  order by price limit 0,1")
    IndexProductVO selectCheap(Integer id);
@Select("select * from attachment where source_id = #{sourceId}")

    Attachment selectUpload(Integer sourceId);
}
